package com.java110.mall.goods.smo.impl;


import com.java110.dto.product.ProductServKeywordDto;
import com.java110.intf.goods.IProductServKeywordInnerServiceSMO;
import com.java110.mall.goods.dao.IProductServKeywordServiceDao;
import com.java110.po.product.ProductServKeywordPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 关键字管理内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ProductServKeywordInnerServiceSMOImpl extends BaseServiceSMO implements IProductServKeywordInnerServiceSMO {

    @Autowired
    private IProductServKeywordServiceDao productServKeywordServiceDaoImpl;


    @Override
    public int saveProductServKeyword(@RequestBody ProductServKeywordPo productServKeywordPo) {
        int saveFlag = 1;
        productServKeywordServiceDaoImpl.saveProductServKeywordInfo(BeanConvertUtil.beanCovertMap(productServKeywordPo));
        return saveFlag;
    }

     @Override
    public int updateProductServKeyword(@RequestBody  ProductServKeywordPo productServKeywordPo) {
        int saveFlag = 1;
         productServKeywordServiceDaoImpl.updateProductServKeywordInfo(BeanConvertUtil.beanCovertMap(productServKeywordPo));
        return saveFlag;
    }

     @Override
    public int deleteProductServKeyword(@RequestBody  ProductServKeywordPo productServKeywordPo) {
        int saveFlag = 1;
        productServKeywordPo.setStatusCd("1");
        productServKeywordServiceDaoImpl.updateProductServKeywordInfo(BeanConvertUtil.beanCovertMap(productServKeywordPo));
        return saveFlag;
    }

    @Override
    public List<ProductServKeywordDto> queryProductServKeywords(@RequestBody  ProductServKeywordDto productServKeywordDto) {

        //校验是否传了 分页信息

        int page = productServKeywordDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            productServKeywordDto.setPage((page - 1) * productServKeywordDto.getRow());
        }

        List<ProductServKeywordDto> productServKeywords = BeanConvertUtil.covertBeanList(productServKeywordServiceDaoImpl.getProductServKeywordInfo(BeanConvertUtil.beanCovertMap(productServKeywordDto)), ProductServKeywordDto.class);

        return productServKeywords;
    }


    @Override
    public int queryProductServKeywordsCount(@RequestBody ProductServKeywordDto productServKeywordDto) {
        return productServKeywordServiceDaoImpl.queryProductServKeywordsCount(BeanConvertUtil.beanCovertMap(productServKeywordDto));    }

    public IProductServKeywordServiceDao getProductServKeywordServiceDaoImpl() {
        return productServKeywordServiceDaoImpl;
    }

    public void setProductServKeywordServiceDaoImpl(IProductServKeywordServiceDao productServKeywordServiceDaoImpl) {
        this.productServKeywordServiceDaoImpl = productServKeywordServiceDaoImpl;
    }
}
